package designpatterns.strategy;

public class Client {
    public static void main(String[] args) {

        BaseAlgorithmStrategy.ExecuteAdd executeAdd = new BaseAlgorithmStrategy.ExecuteAdd();


        //计算器对象
        Calculator calc = new Calculator();
        calc.setStrategy(executeAdd);//传入加法策略，执行加法
        System.out.println(calc.executeStrategy(1,2));

        BaseAlgorithmStrategy.ExecuteSubtract executeSubtract = new BaseAlgorithmStrategy.ExecuteSubtract();
        calc.setStrategy(executeSubtract);//传入减法策略，执行减法
        System.out.println(calc.executeStrategy(1,2));

        //优点：算法不在写死，可以随时扩展
        //缺点：如果算法策略太多的话，会导致代码臃肿。

    }
}
